/* CSS 变量定义 - 允许用户自定义 */
:root {
  --image-optimize-placeholder-bg: #f5f5f5;
  --image-optimize-placeholder-icon-color: #ccc;
  --image-optimize-placeholder-icon-size: 24px;
  --image-optimize-placeholder-min-height: 100px;
  
  --image-optimize-loading-bg: #f5f5f5;
  --image-optimize-loading-icon-color: #409eff;
  --image-optimize-loading-icon-size: 24px;
  
  --image-optimize-error-bg: #f5f5f5;
  --image-optimize-error-icon-color: #ccc;
  --image-optimize-error-icon-size: 24px;
  --image-optimize-error-text-color: #999;
  --image-optimize-error-text-size: 12px;
  --image-optimize-error-min-height: 100px;
  
  --image-optimize-image-cursor: pointer;
}

/* 容器样式 - 使用命名空间前缀避免冲突 */
.image-optimize-container {
  position: relative;
  display: inline-block;
  overflow: hidden;
}

/* 占位符样式 */
.image-optimize-placeholder {
  width: 100%;
  height: 100%;
  background-color: var(--image-optimize-placeholder-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--image-optimize-placeholder-min-height);
}

.image-optimize-placeholder-icon {
  width: var(--image-optimize-placeholder-icon-size);
  height: var(--image-optimize-placeholder-icon-size);
  color: var(--image-optimize-placeholder-icon-color);
}

.image-optimize-placeholder-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* 加载中样式 */
.image-optimize-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--image-optimize-loading-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.image-optimize-loading-icon {
  width: var(--image-optimize-loading-icon-size);
  height: var(--image-optimize-loading-icon-size);
  color: var(--image-optimize-loading-icon-color);
  animation: image-optimize-rotate 1s linear infinite;
}

.image-optimize-loading-icon svg {
  width: 100%;
  height: 100%;
}

@keyframes image-optimize-rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 图片样式 */
.image-optimize-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: var(--image-optimize-image-cursor);
}

/* 错误样式 */
.image-optimize-error {
  width: 100%;
  height: 100%;
  background-color: var(--image-optimize-error-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: var(--image-optimize-error-min-height);
}

.image-optimize-error-icon {
  width: var(--image-optimize-error-icon-size);
  height: var(--image-optimize-error-icon-size);
  color: var(--image-optimize-error-icon-color);
  margin-bottom: 4px;
}

.image-optimize-error-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.image-optimize-error-text {
  font-size: var(--image-optimize-error-text-size);
  color: var(--image-optimize-error-text-color);
}

/* 
 * 样式自定义说明：
 * 1. 使用 CSS 变量覆盖默认样式
 * 2. 通过 className 和 imageClassName 属性添加自定义类名
 * 3. 使用更高优先级的选择器覆盖样式
 * 
 * 示例：
 * :root {
 *   --image-optimize-placeholder-bg: #e0e0e0;
 *   --image-optimize-loading-icon-color: #ff0000;
 * }
 * 
 * .my-custom-image .image-optimize-placeholder {
 *   background-color: #custom-color;
 * }
 */
